<template>
  <div id="account">
    <div class="el_content">
      <el-row class="edit-title">
        <el-col :span="4">新增账号</el-col>
        <el-col :span="3" :offset="17" class="text-right">
          <el-button
            class="back"
            type="info"
            size="mini"
            plain
            icon="el-icon-arrow-left"
            @click="goBack"
          >返回</el-button>
        </el-col>
      </el-row>
      <el-form :model="info" :rules="rules" ref="info" label-width="100px" class="el_t_20">
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="姓名：" prop="name">
              <el-input v-model="info.name" placeholder="请输入姓名"></el-input>
            </el-form-item>
            <el-form-item label="身份证号：" prop="name">
              <el-input v-model="info.name" placeholder="请输入身份证号"></el-input>
            </el-form-item>
            <el-form-item label="联系方式：" prop="name">
              <el-input v-model="info.name" placeholder="请输入联系方式（用于账号登录）"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="性别：" prop="sex">
              <el-radio-group v-model="info.sex">
                <el-radio :label="'男'">男</el-radio>
                <el-radio :label="'女'">女</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="出生日期：">
              <el-date-picker class="el_long" v-model="info.name" type="date" placeholder="选择日期"></el-date-picker>
            </el-form-item>
            <el-form-item label="角色：" prop="name">
              <el-select v-model="info.name" placeholder="医生" class="el_long">
                <el-option label="医生" :value="1"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="所属科室：" prop="name">
              <el-select v-model="info.name" placeholder="睡眠医学中心" class="el_long">
                <el-option label="睡眠医学中心" :value="1"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12" style="line-height:40px;">
            <el-radio-group v-model="info.radio">
              <el-radio :label="1">本院内聘</el-radio>
              <el-radio :label="2">外院特聘</el-radio>
            </el-radio-group>
          </el-col>
          <el-col :span="24">
            <el-form-item label="备注：">
              <el-input type="textarea" :rows="3" placeholder="请输入备注信息"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="签名：">
              <el-upload class="upload" action="https://jsonplaceholder.typicode.com/posts/">
                <img v-if="info.imageUrl" :src="info.imageUrl" class="avatar">
                <template v-else>
                  <i class="el-icon-plus avatar-uploader-icon"></i>
                  <p>电子签名</p>
                </template>
              </el-upload>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="状态：" prop="radio">
              <el-radio-group v-model="info.radio" size="mini">
                <el-radio-button :label="1">正常</el-radio-button>
                <el-radio-button :label="2">冻结</el-radio-button>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <el-row class="footer-fixed">
        <el-col :span="24" class="text-right">
          <el-button type="primary" plain>取 消</el-button>
          <el-button type="primary" @click="submitInfo('info')">保 存</el-button>
        </el-col>
      </el-row>
    </div>
  </div>
</template>
<script>
export default {
  name: "account",
  data() {
    return {
      info: {
        name: "",
        radio: 1,
        sex: "",
        imageUrl: ""
      },
      rules: {
        name: [
          { required: true, message: "医嘱名称不能为空", trigger: "blur" }
        ],
        radio: [
          { required: true, message: "请选择所属分类", trigger: "change" }
        ]
      }
    };
  },
  methods: {
    submitInfo(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          alert("验证通过！");
        } else {
          return false;
        }
      });
    },
    goBack() {
      this.$router.go(-1);
    }
  }
};
</script>
<style scoped>
.el_content {
  width: 100%;
  height: calc(100vh - 150px);
  background: #ffffff;
  padding: 20px;
}
.edit-title {
  padding-bottom: 10px;
  border-bottom: 1px solid #e4e4e4;
  color: #006835;
  font-weight: 700;
}
.upload {
  width: 80px;
  height: 80px;
  background: #f2f2f2;
  color: #999999;
  border: 1px solid #ccc;
  text-align: center;
  border-radius: 4px;
  line-height: 1;
  padding-top: 20px;
}
.upload i {
  font-size: 18px;
}
</style>


